package com.a214.yxz.yuejian013.Activity;

import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;

import com.a214.yxz.yuejian013.R;

public class ClubVideoDetailActivity extends AppCompatActivity {

    private VideoView videoView;
    private MediaController controller;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_club_video_detail);

        String url="http://172.24.10.175/workout/Uploads/tvideo/video/"+getIntent().getStringExtra("url");

        videoView= (VideoView) findViewById(R.id.club_video_detail_videoView);

        controller = new MediaController(this);
        videoView.setMediaController(controller);
        videoView.setVideoURI(Uri.parse(url));
        videoView.start();
        videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mediaPlayer) {
                mediaPlayer.start();
                Toast.makeText(ClubVideoDetailActivity.this, "开始播放", Toast.LENGTH_SHORT).show();
            }
        });
        videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mediaPlayer) {
                Toast.makeText(ClubVideoDetailActivity.this, "播放完毕", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
